package com.example.textview;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.example.textview.PLC.Mythread;
import com.example.textview.util.FxTCP;
import com.example.textview.util.TcpHelper;
import com.example.textview.util.Tcpclass;
import com.example.textview.util.ToastUtil;

public class Plctcp extends AppCompatActivity {


    Button mbtn_connect;
    FxTCP plc;
    Mythread mythread;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_plctcp);
        mythread=new Mythread();

        mythread.setConnectedCallback(new TcpHelper.OnServerConnectedCallbackBlock() {
            @Override
            public void callback() {
                ToastUtil.showMsg(Plctcp.this, "连接成功");
                mythread.start();
            }
        });
    }


    public void connect(View view){

        mythread.ConnectPLC();



    }

    public void set_1(View view){

        mythread.write("Y0",true);
        mythread.write("D602",1.2F);

    }

    public void set_2(View view){
        mythread.write("Y0",false);

        mythread.write("D600",3894);

    }


    public void set_3(View view){


    }


}